import {Api} from "./index.js"
import Request from "@/utils/request.js"
import Message from "@/utils/message.js"

export default function UserApi() {
    console.log("UserApi")
}


export const askCodeServe = async (email) => {
    let result = await Request({
        url: Api.askCode,
        params: {
            email,
            type: "register"
        }
    })
    return result
}

export const GetUserInfo = async (uid) => {
    let result = await Request({
        url: Api.userInfo,
        params: {
            uuid: uid
        }
    })
    return result.data
}

export const Login = async (data) => {
    let results = await Request({
        url: Api.login,
        params: {
            ...data
        }
    })
    return results
}

export const GetRefresh = async () => {
    let result = await Request({
        url: Api.refreshJwt,
    })
    return result
}

export const CaptchaServe = async () => {
    let result = await Request({
        url: Api.Captcha,
    })
    return result
}

export const tximgUrl = async () => {
    let result = await Request({
        url: Api.sourcePath,
        method: "post",
    })
    return result.data
}

export const logoutServe = async ()=>{
    let result = await Request({
        url: Api.logout,
        method: "post",
    })
    return result
}

export const Register = async (email,code,username,password)=>{
    let result = await Request({
        url: Api.register,
        dataType: "json",
        method: "get",
        params: {
            email,
            code,
            username,
            password
        }
    })
    return result
}